const { defineConfig } = require('@vue/cli-service')
const path = require('path')

const proxy_to = target => ({
  ws: false,
  target: 'http://localhost:9005' + target,
  changeOrigin: true,
  secure: false
})

const uploadPath = path.join(__dirname, '..', 'uploads');

console.log('Upload path: ', uploadPath);

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  publicPath: "./",
  devServer: {
    proxy: {
      '/api/book': proxy_to('/zuul-book'),
      '/api/account': proxy_to('/zuul-user'),
      '/api/address': proxy_to('/zuul-address'),
      '/api/cart': proxy_to('/zuul-cart'),
      '/api/comment': proxy_to('/zuul-comment'),
      '/api/order': proxy_to('/zuul-order'),
      '/api/manage/category': proxy_to('/zuul-book'),
      '/api/manage/book': proxy_to('/zuul-book'),
      '/api/manage/performance': proxy_to('/zuul-order'),
      '/api/manage/order': proxy_to('/zuul-order'),
    },
    static: {
        directory: uploadPath,
        publicPath: '/img/',
        watch: false
      }
  }
})
